/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 / / |                                                                                     R S I   M o m e n t u m   T r e n d   I n d i c a t o r                                                                               | 
 
 / / |                                                                             C o p y r i g h t   2 0 2 3 ,   Y o u r N a m e                                                                             | 
 
 / / |                                                                                 h t t p : / / w w w . y o u r w e b s i t e . c o m                                                                         | 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 # p r o p e r t y   c o p y r i g h t   " 2 0 2 3 ,   Y o u r N a m e " 
 
 # p r o p e r t y   l i n k             " h t t p : / / w w w . y o u r w e b s i t e . c o m " 
 
 # p r o p e r t y   v e r s i o n       " 1 . 0 0 " 
 
 # p r o p e r t y   i n d i c a t o r _ s e p a r a t e _ w i n d o w 
 
 # p r o p e r t y   i n d i c a t o r _ b u f f e r s   4 
 
 # p r o p e r t y   i n d i c a t o r _ c o l o r 1   c l r N O N E 
 
 # p r o p e r t y   i n d i c a t o r _ c o l o r 2   c l r N O N E 
 
 # p r o p e r t y   i n d i c a t o r _ c o l o r 3   c l r N O N E 
 
 # p r o p e r t y   i n d i c a t o r _ c o l o r 4   c l r N O N E 
 
 
 
 / / - - -   i n p u t   p a r a m e t e r s 
 
 i n p u t   b o o l   p o s i t i v e               =   f a l s e ; 
 
 i n p u t   b o o l   n e g a t i v e               =   f a l s e ; 
 
 i n p u t   s t r i n g   R S I _ g r o u p                 =   " R S I   S e t t i n g s " ; 
 
 i n p u t   s t r i n g   m o m _ g r o u p                 =   " M o m e n t u m   V a l u e s " ; 
 
 i n p u t   s t r i n g   v i s u a l                       =   " V i s u a l s " ;   
 
 i n p u t   i n t   L e n 2                                 =   1 4 ; 
 
 i n p u t   i n t   p m o m                                 =   6 5 ; 
 
 i n p u t   i n t   n m o m                                 =   3 2 ; 
 
 i n p u t   b o o l   s h o w l a b e l s                   =   t r u e ; 
 
 i n p u t   c o l o r   p                                   =   c l r L i m e ; 
 
 i n p u t   c o l o r   n                                   =   c l r R e d ; 
 
 i n p u t   b o o l   f i l l e s h o w                     =   t r u e ; 
 
 i n p u t   c o l o r   b u l l                             =   c l r L i m e ; 
 
 i n p u t   c o l o r   b e a r                             =   c l r R e d ; 
 
 
 
 / / - - -   i n d i c a t o r   b u f f e r s 
 
 d o u b l e   M o m e n t u m B u f f e r [ ] ; 
 
 d o u b l e   P o s i t i v e S i g n a l B u f f e r [ ] ; 
 
 d o u b l e   N e g a t i v e S i g n a l B u f f e r [ ] ; 
 
 d o u b l e   H i g h l i g h t B u f f e r [ ] ; 
 
 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 / / |   C u s t o m   i n d i c a t o r   i n i t i a l i z a t i o n   f u n c t i o n                                                   | 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 i n t   O n I n i t ( ) 
 
     { 
 
       / /   I n d i c a t o r   b u f f e r s   m a p p i n g 
 
       S e t I n d e x B u f f e r ( 0 ,   M o m e n t u m B u f f e r ) ; 
 
       S e t I n d e x B u f f e r ( 1 ,   P o s i t i v e S i g n a l B u f f e r ) ; 
 
       S e t I n d e x B u f f e r ( 2 ,   N e g a t i v e S i g n a l B u f f e r ) ; 
 
       S e t I n d e x B u f f e r ( 3 ,   H i g h l i g h t B u f f e r ) ; 
 
 
 
       / /   I n d i c a t o r   p r o p e r t i e s 
 
       I n d i c a t o r S h o r t N a m e ( " R S I   M o m e n t u m   T r e n d " ) ; 
 
       S e t I n d e x L a b e l ( 1 ,   " P o s i t i v e   S i g n a l " ) ; 
 
       S e t I n d e x L a b e l ( 2 ,   " N e g a t i v e   S i g n a l " ) ; 
 
 
 
       r e t u r n ( I N I T _ S U C C E E D E D ) ; 
 
     } 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 / / |   C u s t o m   i n d i c a t o r   i t e r a t i o n   f u n c t i o n                                                             | 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 i n t   O n C a l c u l a t e ( c o n s t   i n t   r a t e s _ t o t a l , 
 
                                 c o n s t   i n t   p r e v _ c a l c u l a t e d , 
 
                                 c o n s t   d o u b l e   & p r i c e [ ] ) 
 
     { 
 
       i n t   l i m i t ; 
 
       i f ( r a t e s _ t o t a l   <   L e n 2 ) 
 
             r e t u r n ( 0 ) ; 
 
 
 
       / /   C a l c u l a t e   R S I   v a l u e s   a n d   m o m e n t u m 
 
       l i m i t   =   r a t e s _ t o t a l   -   p r e v _ c a l c u l a t e d ; 
 
       f o r ( i n t   i   =   0 ;   i   <   l i m i t ;   i + + ) 
 
           { 
 
             d o u b l e   r s i   =   i R S I ( S y m b o l ( ) ,   0 ,   L e n 2 ,   P R I C E _ C L O S E ,   i ) ; 
 
             M o m e n t u m B u f f e r [ i ]   =   r s i ; 
 
 
 
             b o o l   p _ m o m   =   M o m e n t u m B u f f e r [ i - 1 ]   <   p m o m   & &   r s i   >   p m o m   & &   r s i   >   n m o m   & &   i M A ( N U L L ,   0 ,   5 ,   0 ,   M O D E _ E M A ,   P R I C E _ C L O S E ,   i )   >   0 ; 
 
             b o o l   n _ m o m   =   r s i   <   n m o m   & &   i M A ( N U L L ,   0 ,   5 ,   0 ,   M O D E _ E M A ,   P R I C E _ C L O S E ,   i )   <   0 ; 
 
 
 
             i f   ( p _ m o m ) 
 
             { 
 
                   P o s i t i v e S i g n a l B u f f e r [ i ]   =   r s i ; 
 
                   N e g a t i v e S i g n a l B u f f e r [ i ]   =   E M P T Y _ V A L U E ; 
 
                   H i g h l i g h t B u f f e r [ i ]   =   r s i ; 
 
             } 
 
             e l s e   i f   ( n _ m o m ) 
 
             { 
 
                   P o s i t i v e S i g n a l B u f f e r [ i ]   =   E M P T Y _ V A L U E ; 
 
                   N e g a t i v e S i g n a l B u f f e r [ i ]   =   r s i ; 
 
                   H i g h l i g h t B u f f e r [ i ]   =   r s i ; 
 
             } 
 
             e l s e 
 
             { 
 
                   P o s i t i v e S i g n a l B u f f e r [ i ]   =   E M P T Y _ V A L U E ; 
 
                   N e g a t i v e S i g n a l B u f f e r [ i ]   =   E M P T Y _ V A L U E ; 
 
                   H i g h l i g h t B u f f e r [ i ]   =   E M P T Y _ V A L U E ; 
 
             } 
 
           } 
 
 
 
       r e t u r n ( r a t e s _ t o t a l ) ; 
 
     } 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 